from kivy.graphics import Color, Line
from kivy.properties import NumericProperty
from kivy.uix.boxlayout import BoxLayout


# 自定义BoxLayout，当做表格的行
class RowLayout(BoxLayout):
    ont_size = NumericProperty(18)  # 默认字体大小

    def __init__(self, **kwargs):
        super(RowLayout, self).__init__(**kwargs)
        self.size_hint_y = None  # 禁用 Y 方向的大小提示
        self.height = 45  # 设置固定高度


        with self.canvas.before:
            # 设置边框
            Color(1, 0, 0, 1)
            self.line = Line(rectangle=(self.x, self.y, self.width, self.height), width=1)

        # 更新矩形和边框的大小和位置
        self.bind(size=self.update_rect, pos=self.update_rect)

    def update_rect(self, *args):
        # 更新边框
        self.line.rectangle = (self.x, self.y, self.width, self.height)
